colinuxfandomcom-20200214-history
Create your own coLinux image by converting it over from another install/VM.
Summary of how it works: *Start with a Linux distribution installed somewhere. **This guide only covers section in general ways. Use your search engine to acquire more info here. **This guide assumes you're sufficiently technically knowledgeable. *Create a coLinux image from that installation. Instructions: *Read thru all the instructions here once to know what preparations are required. *Start with a Linux distribution installed somewhere. **Options include, but not limited to: ***Install Linux distro of your choice to a physical partition in your hard disk. ***Install Linux distro of your choice into VMWare. ***Install Linux distro of your choice into any other virtual machine. **This guide doesn't cover steps for above; use your search engine to find info for above. **The only thing to remember when performing above install is: ***Avoid LVM; coLinux can only support LVM if you recompile its kernel. ***Mark your partitions as ext2 or ext3; ie: /dev/sda1 as ext3. ***Your swap partition should be a separate partition on its own. ****So that you can take it out or change it easily later. **Otherwise, perform above install normally, install any package you wish to have until it's completely installed. **This guide then proceeds on after above install is changed to boot to text mode by default. I did not try proceeding using GUI mode as coLinux may not like it much. **What I did: ***Installed CentOS 5.3 into a VMWare image. ****Had VMWare point to my CentOS*.iso file as CD-ROM drive. ****The image only had 1 NAT network interface; not really necessary. ****Created 2 VMWare hard disks: *****SCSI disk 1 -> 6GB *****SCSI disk 2 -> 512MB ****Modified my partitions to following: *****/dev/sda1 - ext3 -> /boot *****/dev/sda2 - ext3 -> / *****/dev/sdb1 -> swap ***Changed /etc/inittab: ****From id:5:initdefault: ****To id:3:initdefault: ****Above done to ensure CentOS 5.3 boots to text mode. **At this point, we have a Linux distribution to convert to a coLinux image! *Create a coLinux image from that installation. **Run fdisk /dev/sda (assuming you installed to /dev/sda). In my case, I saw something like this: Disk /dev/sdc: 6442 MB, 6442450944 bytes 255 heads, 63 sectors/track, 783 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdc1 * 1''' '''13 104391 83 Linux /dev/sdc2 14 783 6185025 8e Linux LVM **Take note of numbers in bold. ***Total bytes in your /dev/sda: 6442450944 bytes ***Count of bytes in each unit: 8225280 bytes ***Count of units in each of your partitions: 13 and 770 respectively in my case. ****770 783-13 **Also take note what partitions are installed with what & used for what purpose. You'll need this to create your coLinux configuration file. **At this point, you need some place to store images you will extract/create. ***If your install is in a physical hard disk, mount a hard disk & change to a directory where it is mounted. ***If your install is in VMWare, add another hard disk big enough to hold images you will create. In my case, I added a /dev/sdc with 10GB and mounted it to /mnt/clone, and then cd /mnt/clone. **While in your Linux install itself, use its dd command to extract itself to produce coLinux images. The commands I will use are specific to my examples and you may need the command with different parameters depending on how you've installed your earlier Linux. In my case, I used these: ***dd if=/dev/sda1 of=devsda1-boot.img bs=8225280 count=13 ***dd if=/dev/sda2 of=devsda2-root.img bs=8225280 count=770 ***Note: ****Yes we're running off that same hard disk, but it's not that bad. ****There are probably processes not terminated, files not closed, etc. ****But after you created the coLinux image, it's as if you are booting from a power trip. ****Your new Linux image will do some filesystem checks, recover, and all will be fine and dandy. ****If you're paranoid, make a copy of your /dev/sda as /dev/sdc after shutting down, then extract from /dev/sdc instead. This was actually what I did. ****I also did a shortcut; while my VMWare instance was running, from the host computer, I ran following: *****ssh root@ dd if=/dev/sdc1 bs=8225280 count=13 > ./devsda1-boot.img *****ssh root@ dd if=/dev/sdc2 bs=8225280 count=770 > ./devsda2-root.img ****Previous commands delivered my Linux installs straight to my host computer hard disks. **Once you have your devsda1-boot.img and devsda2-root.img files respectively (again your case might differ, depending on how you've installed things), you need those files in your host computer. You'll need to find a way to bring them over to your host computer. ie: ***If you are using a physical install, having the images in your USB hard disk will do. Just plug the hard disk to a Windows machine and copy it to where you want your coLinux image to be. ***If you're using VMWare like I did, you could use the ssh shortcut I mentioned previously if you know how, or you could just copy it out via the network interface from that VMWare, via sftp, scp, ftp or any other means. **Lets say you installed coLinux to C:\Program Files\coLinux and want your images to run from C:\myimage, simply do following: ***Use dd to create a swap image file. ie: dd if=/dev/zero of=swap512m.img bs=1 count=536903680 ***Put your *.img image files into C:\myimage. ***Create a run.bat in C:\myimage, having following content: ****"%ProgramFiles%\coLinux\colinux-daemon" -t nt @"run.conf.txt" ****Create a run.conf.txt file in C:\myimage with your coLinux configuration. In my case, I had these: sda1="devsda1-boot.img" sda2="devsda2-root.img" #cobd0="devsda1-boot.img" #cobd1="devsda2-root.img" #cobd6="CentOS-5.3-i386-bin-DVD.iso" sdb1="swap512m.img" #cobd7="swap512m.img" cofs0="C:\Program Files\coLinux" cofs1="C:\" cofs2="." kernel="C:\Program Files\coLinux\vmlinux" root=/dev/sda2 fastboot # Only needed for first time. #initrd="C:\Program Files\coLinux\initrd.gz" mem=2048 eth0=slirp,02:03:04:05:06:07,tcp:5922:22 #eth1=pcap-bridge,"Loopback-coLinux",02:03:04:05:06:08 eth1=ndis-bridge,"Loopback-coLinux",02:03:04:05:06:08 eth2=tuntap,"TAP-coLinux",02:03:04:05:06:09 ***Yup, the sda1, sda2, and sdb1 entries should correctly pointed coLinux to my Linux images. ***The cofs entries let me access my Windows drives. ***The root entry may need to be modified depending on your install. ***You may need to enable the initrd line by removing the # character at least 1 time. ***As for eth0, eth1, and eth2, I installed Microsoft Loopback Adapter and had my adapters configured in following manner: ****The loopback adapter was renamed to "Loopback-coLinux" (you'll see this in run.conf.txt). Its IP set to 192.168.70.1. ****The TAP adapter was renamed to "TAP-coLinux" (again, you'll see this in run.conf.txt). Its IP set to 192.168.84.1. ***Then, I ran these for CentOS to ensure they can work in the coLinux image after I booted it: cat > /etc/sysconfig/network-scripts/ifcfg-eth0 < DEVICE=eth0 BOOTPROTO=dhcp ONBOOT=yes TYPE=Ethernet INPUTEND cat > /etc/sysconfig/network-scripts/ifcfg-eth1 < DEVICE=eth1 IPADDR=192.168.70.70 NETMASK=255.255.255.0 NETWORK=192.168.70.0 BROADCAST=192.168.70.255 ONBOOT=yes BOOTPROTO=none USERCTL=no INPUTEND cat > /etc/sysconfig/network-scripts/ifcfg-eth2 < DEVICE=eth2 IPADDR=192.168.84.84 NETMASK=255.255.255.0 NETWORK=192.168.84.0 BROADCAST=192.168.84.255 ONBOOT=yes BOOTPROTO=none USERCTL=no INPUTEND ***So with that, from Windows, just double click run.bat & things should run! Just clean up on the install a bit and you now have a coLinux image! 2011 Jul 10 KarHeng Category:Configuration